import java.util.Scanner;


public class Calculations {

	public static void main(String[] args) {
		
		System.out.println("Enter date and time.. (mm dd tttt)");
		Scanner input = new Scanner(System.in);
		
		final int timeOffset = 930;
		final int dayOffset = 7;
		final int monthOffset = 1;
		
		while(true) {
			
			int month = input.nextInt();
			int day = input.nextInt();
			int time = input.nextInt();
			
			if(time < timeOffset) {
				time = 2400 + time - timeOffset;
				day--;
			}
			else {
				time = time - timeOffset;
			}
			
			if(day <= dayOffset) {
				day = 31 + day - dayOffset;
				month--;
			}
			else {
				day = day - dayOffset;
			}
			
			month = month - monthOffset;
			
			System.out.println("Adjusted date and time: " + month + " " + day + " " + time);
			
		}
	}
}
